using Newtonsoft.Json;
using QQZiFramework;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QQZiFramework.Modals
{
    [DBTable(TableName = "A0_OEM")]
    public class OEMInfo : IDBEntity
    {
        public string Name { get; set; }


        string connectionStr { get; set; }
        public string ConnectionStr { set { connectionStr = value; } }

        public string GetConnectionString()
        {
            return connectionStr;
        }
        public string Title { get; set; }


        [JsonIgnore]
        public Newtonsoft.Json.Linq.JObject AppSetting { get; set; }

        public string ExtName { get; set; }

        /// <summary>
        /// 数据库类型，如果空则使用全局的（GlobalDBContextConfig.ProviderName）
        /// </summary>
        public string ProviderName { get; set; }

        Hashtable Arguments = new Hashtable();
        public void RemoveArgument(string name)
        {
            Arguments.Remove(name);
        }

        public T GetOrCreateArgument<T>(string name, Func<T> factory)
        {
            lock (Arguments)
            {
                object obj = Arguments[name];
                if (obj == null)
                {
                    T t = factory();
                    Arguments.Add(name, t);
                    return t;
                }
                else return (T)obj;
            }

        }
    }


}
